/* cGFXBUf.h
 * Holds and renders 8x8 4BPP tiles.
 */
#ifndef __newmoon_cgfxbuf_h
#define __newmoon_cgfxbuf_h

class GFXBuf;
#include <list>
#include <string>
#include <gtk/gtk.h>
#include "debugout.h"
#include "compat.h"
#include "mathx.h"
#include "uint.h"
#include "smw.h"
#include "cROMFile.h"
#include "cCompressorLcLz2.h"
#include "cCompressor3BPP.h"
#include "gui/cDrawBox.h"

class GFXBuf {
	public:
		static const u32 TileSize;
		GFXBuf();
		GFXBuf(u32 NumTiles);
		~GFXBuf();
		u8* GetBuffer();
		u32 GetNumTiles();
		u32 LoadFromFile(std::string Filename, u32 Addr, u32 NumTiles, u32 DestTile, CompressionFormat Compression);
		u32 LoadFromFile(FILE *File, u32 Addr, u32 NumTiles, u32 DestTile, CompressionFormat Compression);
		u32 LoadFromROM(ROMFile *ROM, u32 Addr, u32 NumTiles, u32 DestTile, CompressionFormat Compression);
		u32 LoadFromROM(ROMFile *ROM, SNESPointer *Ptr, u32 NumTiles, u32 DestTile, CompressionFormat Compression);
		bool RenderTile(u32 Tile, u16 *Pal, ImgBuf *Dest, u32 DX, u32 DY, bool Transparent, bool XFlip, bool YFlip);
		bool RenderTile(u32 Tile, u16 *Pal, ImgBuf *Dest, u32 DX, u32 DY, bool Transparent);
		bool RenderRawTile(u16 Tile, u16 *Pal, ImgBuf *Dest, u32 DX, u32 DY, bool Transparent);
		bool RenderMagnifiedTile(u32 Tile, u16 *Pal, ImgBuf *Dest, u32 DX, u32 DY, bool Transparent, bool XFlip, bool YFlip, u32 Mag);
		bool RenderMagnifiedTile(u32 Tile, u16 *Pal, ImgBuf *Dest, u32 DX, u32 DY, bool Transparent, u32 Mag);
		bool RenderMagnifiedRawTile(u16 Tile, u16 *Pal, ImgBuf *Dest, u32 DX, u32 DY, bool Transparent, u32 Mag);
		bool CopyTiles(u32 Tile, GFXBuf *Dest, u32 DestTile, u32 NumTiles);
	
	protected:
		u8 *Buf;
		u32 NumTiles;
	
	private:
		void _Create(u32 NumTiles);
};

#endif //__newmoon_cgfxbuf_h
